package com.atguigu.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.atguigu.entity.Dict;
import com.atguigu.result.Result;
import com.atguigu.service.DictService;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName DictController
 * @Description 此类描述:
 * @Author dangchen
 * @DateTime 2022-08-27 23:26
 * @Version 1.0
 */
@RestController
@RequestMapping("/dict")
public class DictController{

    @Reference
    private DictService dictService;

    // /dict/findListByDictCode/**Type
    //根据编码获取子节点数据列表
    @RequestMapping("/findListByDictCode/{dictCode}")
    public Result<List<Dict>> findListByDictCode(@PathVariable String dictCode){
        List<Dict> list = dictService.findListByDictCode(dictCode);
        return Result.ok(list);
    }

    // /dict/findListByParentId/" + id
    //根据上级id获取子节点数据列表
    @RequestMapping("findListByParentId/{parentId}")
    public Result<List<Dict>> findListByParentId(@PathVariable Long parentId){
        List<Dict> list = dictService.findListByParentId(parentId);
        return Result.ok(list);
    }
}
